package windows;

import java.awt.Dimension;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;

public class AddAngajatFrame {
	private JFrame frame;

	private JTextField textField_NumeAngajat = new JTextField();
	private JTextField textField_ContAngajat = new JTextField();
	private JTextField textField_SumaAngajat = new JTextField();
	private JComboBox comboBox_BancaAngajat = new JComboBox();
	private JButton saveAngajatButton = new JButton("Save");
	private JButton cancelAngajatButton = new JButton("Cancel");
	private boolean openedFirstTime = true;

	

	public void setFrame() {
		JPanel panel = new JPanel();
		frame = new JFrame("Adaugare angajat");

		JLabel numeAngajatLabel = new JLabel(
				"Introduceti numele complet al angajatului:");
		JLabel contAngajatLabel = new JLabel("Introduceti contul angajatului:");
		JLabel sumaAngajatLabel = new JLabel("Introduceti suma angajatului:");
		JLabel bancaAngajatLabel = new JLabel("Selectati banca:");
		SpringLayout layout = new SpringLayout();

		panel.setLayout(layout);

		panel.add(numeAngajatLabel);
		panel.add(contAngajatLabel);
		panel.add(sumaAngajatLabel);
		panel.add(bancaAngajatLabel);
		panel.add(textField_NumeAngajat);
		panel.add(textField_ContAngajat);
		panel.add(textField_SumaAngajat);
		panel.add(comboBox_BancaAngajat);
		panel.add(saveAngajatButton);
		panel.add(cancelAngajatButton);

		textField_NumeAngajat.setPreferredSize(new Dimension(250, 30));
		textField_ContAngajat.setPreferredSize(new Dimension(250, 30));
		textField_SumaAngajat.setPreferredSize(new Dimension(250, 30));
		comboBox_BancaAngajat.setPreferredSize(new Dimension(250, 25));

		saveAngajatButton.setActionCommand("saveAngajat");
		cancelAngajatButton.setActionCommand("cancelAngajat");

		layout.putConstraint(SpringLayout.WEST, numeAngajatLabel, 100,
				SpringLayout.WEST, panel);
		layout.putConstraint(SpringLayout.NORTH, numeAngajatLabel, 20,
				SpringLayout.NORTH, panel);

		layout.putConstraint(SpringLayout.WEST, textField_NumeAngajat, 90,
				SpringLayout.WEST, panel);
		layout.putConstraint(SpringLayout.NORTH, textField_NumeAngajat, 10,
				SpringLayout.SOUTH, numeAngajatLabel);

		layout.putConstraint(SpringLayout.WEST, contAngajatLabel, 130,
				SpringLayout.WEST, panel);
		layout.putConstraint(SpringLayout.NORTH, contAngajatLabel, 10,
				SpringLayout.SOUTH, textField_NumeAngajat);

		layout.putConstraint(SpringLayout.WEST, textField_ContAngajat, 90,
				SpringLayout.WEST, panel);
		layout.putConstraint(SpringLayout.NORTH, textField_ContAngajat, 10,
				SpringLayout.SOUTH, contAngajatLabel);

		layout.putConstraint(SpringLayout.WEST, sumaAngajatLabel, 130,
				SpringLayout.WEST, panel);
		layout.putConstraint(SpringLayout.NORTH, sumaAngajatLabel, 10,
				SpringLayout.SOUTH, textField_ContAngajat);

		layout.putConstraint(SpringLayout.WEST, textField_SumaAngajat, 90,
				SpringLayout.WEST, panel);
		layout.putConstraint(SpringLayout.NORTH, textField_SumaAngajat, 10,
				SpringLayout.SOUTH, sumaAngajatLabel);

		layout.putConstraint(SpringLayout.WEST, bancaAngajatLabel, 170,
				SpringLayout.WEST, panel);
		layout.putConstraint(SpringLayout.NORTH, bancaAngajatLabel, 10,
				SpringLayout.SOUTH, textField_SumaAngajat);

		layout.putConstraint(SpringLayout.WEST, comboBox_BancaAngajat, 90,
				SpringLayout.WEST, panel);
		layout.putConstraint(SpringLayout.NORTH, comboBox_BancaAngajat, 10,
				SpringLayout.SOUTH, bancaAngajatLabel);

		layout.putConstraint(SpringLayout.WEST, saveAngajatButton, 150,
				SpringLayout.WEST, panel);
		layout.putConstraint(SpringLayout.NORTH, saveAngajatButton, 10,
				SpringLayout.SOUTH, comboBox_BancaAngajat);

		layout.putConstraint(SpringLayout.WEST, cancelAngajatButton, 10,
				SpringLayout.EAST, saveAngajatButton);
		layout.putConstraint(SpringLayout.NORTH, cancelAngajatButton, 10,
				SpringLayout.SOUTH, comboBox_BancaAngajat);

		frame.setSize(450, 500);
		frame.getContentPane().add(panel);
	}

	public JFrame getFrame() {
		return frame;
	}

	public JTextField getTextField_NumeAngajat() {
		return textField_NumeAngajat;
	}

	public JTextField getTextField_ContAngajat() {
		return textField_ContAngajat;
	}

	public JTextField getTextField_SumaAngajat() {
		return textField_SumaAngajat;
	}

	public JComboBox getComboBox_BancaAngajat() {
		return comboBox_BancaAngajat;
	}

	public JButton getSaveAngajatButton() {
		return saveAngajatButton;
	}

	public JButton getCancelAngajatButton() {
		return cancelAngajatButton;
	}
	public boolean isOpenedFirstTime() {
		return openedFirstTime;
	}

	public void setOpenedFirstTime(boolean openedFirstTime) {
		this.openedFirstTime = openedFirstTime;
	}

	public void showFrame() {
		frame.setVisible(true);

	}

	public void hideFrame() {
		frame.setVisible(false);

	}

	public void dispose() {
		frame.dispose();

	}

	public void showError(String error) {

		JOptionPane.showMessageDialog(frame, error, "Error",
				JOptionPane.ERROR_MESSAGE);

	}

}
